package edu.isistan.metamodel;

/**
 * A wrapper for collections
 */
public class Collection extends DataType {
	
	private DataType dataType;
	private String collectionType = null;

	public Collection() {
	
	}
	
	public Collection(String name, DataType dataType, String doc) {
		this.name = name;
		this.doc = doc;
		this.dataType = dataType;
		this.dataType.setPartOf(this);
	}
	
	@Override
	public void setCardinality(int cardinality) {
		dataType.setCardinality(cardinality);
		this.cardinality = cardinality;
	}
	
	@Override
	public String getType() {
		return dataType.getType();
	}

	public DataType getDataType() {
		return dataType;
	}
	
	@Override
	public boolean isPrimitive() {
		return false;
	}

	@Override
	public boolean isCollection() {
		return true;
	}
	
	@Override
	public boolean isWrapper() {
		return dataType.isWrapper();
	}
	
	@Override
	public boolean isCompoused() {
		return dataType.isCompoused();
	}
	
	@Override
	public boolean isArray() {
		return dataType.isArray();
	}
	
	public String getCollectionType() {
		return collectionType;
	}

	public void setCollectionType(String collectionType) {
		this.collectionType = collectionType;
	}

	@Override
	public String toString() {
		String result=new String();
		result+="Colection <"+getType()+"> "+name+" ";
		return result;
	}

	@Override
	public String getPrettyPrintType() {
		StringBuffer sb = new StringBuffer();
		sb.append(getCollectionType());
		sb.append("<");
		sb.append(getDataType().getPrettyPrintType());
		sb.append(">");
		return sb.toString();
	}
}